

*************************************************************************************************************
**
*Table A.6: Effects on market prices and overcharges
*This table reports estimated treatment effects on the market prices reported by beneffciaries, market prices reported by FPS dealers, statutory prices, and total overcharges (Panel D) in endline one (January - March)
*************************************************************************************************************



*******************************************************************************
* Household reported local market prices
*******************************************************************************
use "${SurveyDataDir}/JH_ePOS_HH_DataforAnalysis.dta",clear

keep if ss_code == "SS01"

drop if ghost_final==1

svyset [pw = pweight]


count if ghost_final == 1
scalar ghosts = r(N)
scalar obs = 3960   

*Get relative weights of AAY and PH rationcard holders by whether RC is in an urban area
sum pweight if rationcardtype == "AAY" & isurban == 0
scalar AAY_weight0 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 0
scalar PH_weight0 = r(sum)

sum pweight if rationcardtype == "AAY" & isurban == 1
scalar AAY_weight1 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 1
scalar PH_weight1 = r(sum)


preserve
*Merge in original FPS codes                                              //merge in pweight to calculate fps_weight
use "${AdminDataDir}/FPS_sampling_prob.dta", clear 
rename pweight fps_weight 

keep district_code block_code fps_code fps_weight

collapse fps_weight, by(district_code block_code fps_code)



tempfile sampledat
save `sampledat', replace
restore


collapse(median) d2_co_*_kirana_price_fps d2_co_*_kirana_price_block pweight, by(district_code block_code fps_code strata treatment) 
merge m:1 district_code block_code fps_code using `sampledat', keep(3) nogen


*change varnames:
rename d2_co_1_kirana_price_fps d2_co_rice_kirana_price_fps
rename d2_co_2_kirana_price_fps d2_co_wheat_kirana_price_fps
rename d2_co_3_kirana_price_fps d2_co_sugar_kirana_price_fps
rename d2_co_4_kirana_price_fps d2_co_salt_kirana_price_fps
rename d2_co_5_kirana_price_fps d2_co_kero_kirana_price_fps

count
scalar fps_obs = 396

drop pweight
rename fps_weight pweight
svyset [pw = pweight]

loc ration "rice wheat sugar salt kero"

loc tflist " "
foreach rat of local ration {

qui svy: mean d2_co_`rat'_kirana_price_fps if treatment == 0
qui estat sd
matrix Mean0 = r(mean)

eststo `rat'_price: xi: reg d2_co_`rat'_kirana_price_fps treatment i.strata [pw = pweight], cluster(block_code)
estadd scalar control_mean = `=Mean0[1,1]'
estadd scalar percent_obs 100*e(N)/fps_obs

tempfile mar_`rat'
parmest, label saving("`mar_`rat''")
local tflist "`tflist' `mar_`rat''"

}


dsconcat `tflist',subset(parm p in 1) dsn(ds_ration)       
qqvalue p, method(yekutieli) qvalue(qval)
mkmat qval

 
forval i = 1/5 {
local estname: word `i' of `tflist'
local rat: word `i' of `ration'

estimates restore `rat'_price  

mat bet=e(b)                    

mat bet[1,1]=qval[`i',1]            
mat list bet      

estadd matrix qvalue = bet               
                                            
mat list e(qvalue)   


}



eststo dummy: reg p qval
estadd scalar control_mean=.,replace
estadd scalar N=.,replace	
	
loc tabname "${OutputDir}/TableA_6.tex"
cd "${adoDir}"
loc nc 6

MultiPartTabStart, ///
			ncol(`nc') tabname(`tabname') ///
			colnames("Total" "Rice" "Wheat" "Sugar" "Salt" "Kerosene") width("\hsize") ///
			
MultiPartTabPanelStart, ///
			ncol(`nc') tabname(`tabname') ///
			panelstring("Panel A: Local market prices---reported by households")
			
			
MultiPartTabPanelEnd, ///
				ncol(`nc') tabname(`tabname') ///
				models("dummy rice_price wheat_price sugar_price salt_price kero_price") ///
				cells(b(star fmt(%12.2g) ) se(par(( )) fmt(%12.2g) ) qvalue(par([ ]) fmt(2))  )  ///
				stats(control_mean N, label("Control mean" "Observations") fmt(%12.2g %15.0fc)) starlevels( * 0.10 ** 0.05 *** 0.01) ///
				varlabels(treatment "Treatment" , elist(treatment \addlinespace ) ) ///
				drop(_cons  _Istrata* qval)


eststo cr 





*******************************************************************************
* Dealer reported local market prices 
*******************************************************************************

use "${SurveyDataDir}/JHePOS_EL1_Dealer_data.dta",clear
tostring fps_uid, replace
drop if fps_uid == "."
merge 1:1 fps_uid using "${SurveyDataDir}/JHePOS_BL_Dealer_data.dta", keepusing(*_y0) nogen

tostring district_code, replace format("%02.0f")
tostring block_code, replace format("%03.0f")
tostring fps_code, replace format("%02.0f")


*Merge in Strata 
merge m:1 block_code using "${AdminDataDir}/blockLevel_strata.dta", keep(3) keepusing(strata)
drop _merge

qui distinct district_code block_code, j
assert `r(ndistinct)' == 132 


svyset [pw = pweight]


*Number of originally sampled FPS
scalar fps_obs = 396


local tflist_noBL ""
preserve
scalar obs = 396
keep if fps_new_yesno == 0

local ration "rice wheat sugar salt kero"
foreach rat of local ration{

qui svy: mean b14_cost_commodity_`rat' if treatment == 0 
qui estat sd
matrix Mean0 = r(mean)
eststo mar_`rat': xi: reg b14_cost_commodity_`rat' treatment i.strata [pw = pweight], cluster(block_code)
estadd scalar control_mean = `=Mean0[1,1]'
estadd scalar percent_obs 100*e(N)/obs

tempfile mar_`rat'
parmest, label saving("`mar_`rat''")
local tflist_noBL "`tflist_noBL' `mar_`rat''"

}

restore


dsconcat `tflist_noBL',subset(parm p in 1) dsn(ds_ration)
qqvalue p, method(yekutieli) qvalue(qval)
mkmat qval

 
forval i = 1/5 {
local estname: word `i' of `tflist_noBL'
local rat: word `i' of `ration'

estimates restore mar_`rat'


mat bet=e(b)                    

mat bet[1,1]=qval[`i',1]             
mat list bet      

estadd matrix qvalue = bet               
                                            
mat list e(qvalue)   

}


eststo dummy: reg p qval
estadd scalar control_mean=.,replace
estadd scalar N=.,replace

			
MultiPartTabPanelStart, ///
			ncol(`nc') tabname(`tabname') ///
			panelstring("Panel B: Local market prices---reported by dealers (Rs)")
			
			
MultiPartTabPanelEnd, ///
				ncol(`nc') tabname(`tabname') ///
				models("dummy mar_rice mar_wheat mar_sugar mar_salt mar_kero") ///
				cells(b(star fmt(%12.2g) ) se(par(( )) fmt(%12.2g) ) qvalue(par([ ]) fmt(2))  )  ///
				stats(control_mean N, label("Control mean" "Observations") fmt(%12.2g %15.0fc)) starlevels( * 0.10 ** 0.05 *** 0.01) ///
				varlabels(treatment "Treatment" , elist(treatment \addlinespace ) ) ///
				drop(_cons  _Istrata* qval)

				
eststo cr
				
				
				
				
				
*******************************************************************************
* Statutory kerosene prices
*******************************************************************************
		
	

use "${AdminDataDir}/Statutory_Kerosene_Prices.dta",clear

*Merge in Strata andd treatment status
merge m:1 block_code using "${AdminDataDir}/blockLevel_strata.dta", keepusing(strata treatment)nogen


*******************************************
* Impact on statutory kerosene prices

count
scalar obs = 132

egen bl_var = rowmean(stat_price_kero_mar16 stat_price_kero_apr16 stat_price_kero_may16)
egen bl_var_mean = mean(bl_var)
gen bl_var_mi = missing(bl_var)
replace bl_var = bl_var_mean if bl_var_mi == 1


preserve
keep stat_price_kero_jan17 stat_price_kero_feb17 stat_price_kero_mar17 treatment  bl_var bl_var_mi strata block_code
rename stat_price_kero_jan17 price1
rename stat_price_kero_feb17 price2
rename stat_price_kero_mar17 price3

reshape long price, i(block_code) j(month)


count
scalar obs_all = 3*132

qui: mean price if treatment == 0 
qui estat sd
matrix Mean0 = r(mean)
eststo pool1BL: xi: reg price treatment bl_var bl_var_mi i.strata , cluster(block_code)
estadd scalar control_mean = `=Mean0[1,1]'
estadd scalar percent_obs 100*e(N)/obs_all

restore



*Output table for paper w/ placeholders for other ration commodities

gen placeholder1 = 0
gen placeholder2 = 0
gen placeholder3 = 0
gen placeholder4 = 0

forval i = 1/4{

qui: mean placeholder`i' if treatment == 0 
qui estat sd
matrix Mean0 = r(mean)
eststo pool_ph`i': xi: reg placeholder`i' treatment i.strata , cluster(block_code)
estadd scalar N=.,replace
}
		
		
eststo dummy: reg placeholder1 placeholder2
estadd scalar control_mean=.,replace
estadd scalar N=.,replace			
				
MultiPartTabPanelStart, ///
			ncol(`nc') tabname(`tabname') ///
			panelstring("Panel C: Statutory prices")
			
			
MultiPartTabPanelEnd, ///
				ncol(`nc') tabname(`tabname') ///
				models("dummy pool_ph* pool1BL") ///
				cells(b(star fmt(%12.2g) ) se(par(( )) fmt(%12.2g) ) qvalue(par([ ]) fmt(2))  )  ///
				stats(control_mean N, label("Control mean" "Observations") fmt(%12.2g %15.0fc)) starlevels( * 0.10 ** 0.05 *** 0.01) ///
				varlabels(treatment "Treatment" , elist(treatment \addlinespace  ) ) ///
				drop(_cons  _Istrata* bl_var_mi placeholder2 bl_var) ///
				substitute("&               &           0   &           0   &           0   &           0   &" "& & -- & -- & -- & -- &"  ///
				"&               &         (.)   &         (.)   &         (.)   &         (.)   &" "& & & & & &"  ///
				"&           .   &               &               &               &               &" "& & -- & -- & -- & -- &"   ///
				"&           .   &         132   &         132   &         132   &         132   &"  "& & -- & -- & -- & -- &"  )
				
				
				
				
		
*******************************************************************************
* Overcharges
*******************************************************************************
	

use "${SurveyDataDir}/JH_ePOS_HH_DataforAnalysis.dta",clear


keep if ss_code == "SS01"

svyset [pw = pweight]


count if ghost_final == 1
scalar ghosts = r(N)
scalar obs = 3960   

*Get relative weights of AAY and PH rationcard holders by whether RC is in an urban area
sum pweight if rationcardtype == "AAY" & isurban == 0
scalar AAY_weight0 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 0
scalar PH_weight0 = r(sum)

sum pweight if rationcardtype == "AAY" & isurban == 1
scalar AAY_weight1 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 1
scalar PH_weight1 = r(sum)



count
scalar obs = 3960 

local tflist ""
local tflist_noBL ""

*Analysis
loc ration "rice wheat sugar salt kero"

local tflist ""

foreach rat of local ration{
gen bl_var = b_overcharge_`rat'_y0
egen bl_var_mean = mean(bl_var)
gen bl_var_mi = missing(bl_var)
replace bl_var = bl_var_mean if bl_var_mi == 1


preserve
keep uid b_overcharge_`rat'_jan17 b_overcharge_`rat'_feb17 b_overcharge_`rat'_mar17 bl_var bl_var_mi treatment strata pweight block_code
gen b_overcharge_`rat'3 = b_overcharge_`rat'_mar17
gen b_overcharge_`rat'2 = b_overcharge_`rat'_feb17
gen b_overcharge_`rat'1 = b_overcharge_`rat'_jan17
drop b_overcharge_`rat'_jan17 b_overcharge_`rat'_feb17 b_overcharge_`rat'_mar17
reshape long b_overcharge_`rat', i(uid) j(month)

count
scalar obs_all = 3*(3960 - ghosts)


qui svy: mean b_overcharge_`rat' if treatment == 0 
qui estat sd
matrix Mean0 = r(mean)

eststo `rat'poolBL1: xi: reg b_overcharge_`rat' treatment bl_var bl_var_mi i.strata [pw = pweight], cluster(block_code)
estadd scalar control_mean = `=Mean0[1,1]'
estadd scalar percent_obs 100*e(N)/obs_all

tempfile `rat'poolBL1
parmest, label saving("``rat'poolBL1'")
local tflist "`tflist' ``rat'poolBL1'"



restore

drop bl_var*
}

*Total overcharge
preserve

gen bl_var = b_overcharge_total_y0
egen bl_var_mean = mean(bl_var)
gen bl_var_mi = missing(bl_var)
replace bl_var = bl_var_mean if bl_var_mi == 1

keep uid b_overcharge_total_*17 bl_var bl_var_mi treatment strata pweight block_code
gen b_overcharge_total3 = b_overcharge_total_mar17
gen b_overcharge_total2 = b_overcharge_total_feb17
gen b_overcharge_total1 = b_overcharge_total_jan17
drop b_overcharge_total_*17
reshape long b_overcharge_total, i(uid) j(month)

count
scalar obs_all = 3*(3960 - ghosts)


qui svy: mean b_overcharge_total if treatment == 0 
qui estat sd
matrix Mean0 = r(mean)

eststo totalpoolBL1: xi: reg b_overcharge_total treatment bl_var bl_var_mi i.strata [pw = pweight], cluster(block_code)
estadd scalar control_mean = `=Mean0[1,1]'
estadd scalar percent_obs 100*e(N)/obs_all


drop bl_var*
restore


*Write tables
preserve
dsconcat `tflist', subset(parm p in 1) dsn(ds_ration)  
qqvalue p, method(yekutieli) qvalue(qval)
mkmat qval

 
forval i = 1/5 {
local rat: word `i' of `ration'
estimates restore `rat'poolBL1

mat bet=e(b)                   

mat bet[1,1]=qval[`i',1]             
mat list bet      
estadd matrix qvalue = bet               
                                            
mat list e(qvalue) 


}

MultiPartTabPanelStart, ///
			ncol(`nc') tabname(`tabname') ///
			panelstring("Panel D: Overcharges")
			
			
MultiPartTabPanelEnd, ///
				ncol(`nc') tabname(`tabname') ///
				models("totalpoolBL1 ricepoolBL1 wheatpoolBL1 sugarpoolBL1 saltpoolBL1 keropoolBL1") ///
				cells(b(star fmt(%12.2g) ) se(par(( )) fmt(%12.2g) ) qvalue(par([ ]) keep(treatment) fmt(2))  )  ///
				stats(control_mean N, label("Control mean" "Observations") fmt(%12.2g %15.0fc)) starlevels( * 0.10 ** 0.05 *** 0.01) ///
				varlabels(treatment "Treatment" , elist(treatment \addlinespace   )  ) ///
				drop(_cons _Istrata* bl_var_mi bl_var)							
				
				
MultiPartTabEnd, ///
			ncol(`nc') tabname(`tabname') 
